const statisticModel = require('@/models/statistic.model')
const JsonResult = require('@/utils/httpResponse.util')

class StatisticController {
  async statisticCountall (req, response) {
    try {
      const data = await statisticModel.statisticCountall()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async publicContentTrend (req, response) {
    try {
      const data = await statisticModel.publicContentTrend()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async statisticVisitCounts (req, response) {
    try {
      const data = await statisticModel.statisticVisitCounts()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async findHotTags (req, response) {
    try {
      const data = await statisticModel.findHotTags()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async fingHotArticle (req, response) {
    try {
      const data = await statisticModel.fingHotArticle()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async visitCountFronCity (req, response) {
    try {
      const data = await statisticModel.visitCountFronCity()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }
}

module.exports = new StatisticController()
